﻿using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using INdT_Core.BO;
using INdT_Core.Entity;
using System.Web.UI.MobileControls;
using System.Collections.Generic;
using System.Web.UI.HtmlControls;

namespace INdT_Sharepoint.Organograma.Organograma
{
    [ToolboxItem(false)]
    public partial class Organograma : System.Web.UI.WebControls.WebParts.WebPart
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            InitializeControl();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            OrganogramaBO organogramaBO = new OrganogramaBO();
            List<INdT_Core.Entity.Organograma> lista = organogramaBO.GetAll();
            rptOrganograma.DataSource = lista;
            rptOrganograma.DataBind();
        }


        protected void rptOrganograma_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                INdT_Core.Entity.Organograma organogramaItem = (INdT_Core.Entity.Organograma)e.Item.DataItem;
                HtmlGenericControl divOrganograma = (HtmlGenericControl)e.Item.FindControl("divOrganograma");
                HyperLink hlPessoa = (HyperLink)e.Item.FindControl("hlPessoa");
                System.Web.UI.WebControls.Label litDepartamento = (System.Web.UI.WebControls.Label)e.Item.FindControl("litDepartamento");
                divOrganograma.Attributes.Add("class", "organogramaItem organograma" + organogramaItem.Identificador);
                hlPessoa.Text = organogramaItem.Colaborador.Nome;
                hlPessoa.NavigateUrl = "../../Lists/Pessoas/DispForm.aspx?ID=" + organogramaItem.Colaborador.Id.ToString();
                litDepartamento.Text = organogramaItem.Departamento;
            }
        }
    }
}
